import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;

public class Test1 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		String testLog = getTestLog();
		//testLog = testLog.replaceAll("\r", "");
		String Flag_BEGIN="[BEGIN]";
		String Flag_END="[END]";
		int indexBegin = testLog.indexOf(Flag_BEGIN);
		int indexEnd = testLog.indexOf(Flag_END);
		testLog = testLog.substring(indexBegin+Flag_BEGIN.length(),indexEnd);
		String[] lines = testLog.split("\n");
		int upnCount=0;
		for(int i=0;i<lines.length;i++){
			//System.out.print(lines[i]);
			String[] items = lines[i].split("=");
			if(items.length == 1)
				continue;
			String itemName = items[0].trim();
			if(!itemName.startsWith("UPN") && !itemName.endsWith("UPN"))
				continue;
			String itemValue = items[1];	
			
			if(upnCount!=0)
				System.out.print(",");
			
			System.out.print(itemValue.trim());
			upnCount++;
		}
		
	}

	private static String getTestLog(){
		FileInputStream fin;
		StringBuilder sb= new StringBuilder();
		try {
			// Open an output stream
			fin = new FileInputStream("/home/jack/test_log.txt");

			BufferedReader d = new BufferedReader(new InputStreamReader(fin));

			
			while(d.ready()){
				String line = d.readLine();
				sb.append(line+"\r\n");				
			}
			
			// Close our output stream
			fin.close();
			
			
		}
		// Catches any error conditions
		catch (IOException e) {
			System.err.println("Unable to write to file");
			System.exit(-1);
		}
		
		return sb.toString();
				
	}
}
